package com.baox.agridata.synchronous.service.impl;

import com.baox.agridata.synchronous.dao.ReceivePointMapper;
import com.baox.agridata.synchronous.entity.TUserQUADECPointEntiy;
import com.baox.agridata.synchronous.service.ReceivePointService;
import com.baox.agridata.synchronous.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author: yxc
 * @date: 2023/12/18 14:36
 * @Description: 处理成都推来的申报点数据
 */
@Slf4j
@Service
public class ReceivePointServiceImpl implements ReceivePointService {

    @Autowired
    ReceivePointMapper asyncPointMapper;

    @Override
    public void receiveSiChuanTUserQUADECPoint(List<TUserQUADECPointEntiy> l_list) {
        StringBuilder sb = new StringBuilder();
        sb.append(".java").append(DateUtil.dateConvertTag(new Date()));
        log.info("本次的批次号为：" + sb.toString());
        if (l_list.size()>0){
            for (TUserQUADECPointEntiy data : l_list) {
                TUserQUADECPointEntiy tccpaEntity = asyncPointMapper.selectTUserQUADECPointById(data.getMid());
                if (tccpaEntity == null) {
                    data.setSourceId(sb.toString());
                    asyncPointMapper.insertIntoTUserQUADECPoint(data);
                }else {
                    data.setSourceId(sb.toString());
                    asyncPointMapper.updatetoTUserQUADECPoint(data);
                }
            }
        }
    }


}
